import { insert, patchProps, setElementText } from "../browserRendererOptions"
import patch from "./patch"

export default function mountElement(vnode, container, anchor){
  const {type, children, props} = vnode
  const el = createElement(type)
  if(typeof children === 'string') {
    setElementText(el, children)
  } else if(Array.isArray(children)) {
    children.forEach(child=> {
      patch(null, child, el, anchor)
    })
  }
  if(props) {
    for(const key in props) {
      patchProps(el, key, null, props[key])
    }
  }
  insert(el, container)
}